package dto

import (

	"go-admin/app/admin/models"
	"go-admin/common/dto"
	common "go-admin/common/models"
)

type ReviewsGetPageReq struct {
	dto.Pagination     `search:"-"`
    UserId int64 `form:"userId"  search:"type:exact;column:user_id;table:reviews" comment:"用户ID"`
    AdvertisementId int64 `form:"advertisementId"  search:"type:exact;column:advertisement_id;table:reviews" comment:"广告ID"`
    Rating int64 `form:"rating"  search:"type:exact;column:rating;table:reviews" comment:"分数"`
    Content string `form:"content"  search:"type:contains;column:content;table:reviews" comment:"内容"`
    ReviewsOrder
}

type ReviewsOrder struct {
    Id string `form:"idOrder"  search:"type:order;column:id;table:reviews"`
    UserId string `form:"userIdOrder"  search:"type:order;column:user_id;table:reviews"`
    AdvertisementId string `form:"advertisementIdOrder"  search:"type:order;column:advertisement_id;table:reviews"`
    Rating string `form:"ratingOrder"  search:"type:order;column:rating;table:reviews"`
    Content string `form:"contentOrder"  search:"type:order;column:content;table:reviews"`
    Images string `form:"imagesOrder"  search:"type:order;column:images;table:reviews"`
    CreateBy string `form:"createByOrder"  search:"type:order;column:create_by;table:reviews"`
    UpdateBy string `form:"updateByOrder"  search:"type:order;column:update_by;table:reviews"`
    CreatedAt string `form:"createdAtOrder"  search:"type:order;column:created_at;table:reviews"`
    UpdatedAt string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:reviews"`
    DeletedAt string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:reviews"`
    
}

func (m *ReviewsGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type ReviewsInsertReq struct {
    Id int `json:"-" comment:""` // 
    UserId int64 `json:"userId" comment:"用户ID"`
    AdvertisementId int64 `json:"advertisementId" comment:"广告ID"`
    Rating int64 `json:"rating" comment:"分数"`
    Content string `json:"content" comment:"内容"`
    Images string `json:"images" comment:"图片"`
    common.ControlBy
}

func (s *ReviewsInsertReq) Generate(model *models.Reviews)  {
    if s.Id == 0 {
        model.Model = common.Model{ Id: s.Id }
    }
    model.UserId = s.UserId
    model.AdvertisementId = s.AdvertisementId
    model.Rating = s.Rating
    model.Content = s.Content
    model.Images = s.Images
    model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

func (s *ReviewsInsertReq) GetId() interface{} {
	return s.Id
}

type ReviewsUpdateReq struct {
    Id int `uri:"id" comment:""` // 
    UserId int64 `json:"userId" comment:"用户ID"`
    AdvertisementId int64 `json:"advertisementId" comment:"广告ID"`
    Rating int64 `json:"rating" comment:"分数"`
    Content string `json:"content" comment:"内容"`
    Images string `json:"images" comment:"图片"`
    common.ControlBy
}

func (s *ReviewsUpdateReq) Generate(model *models.Reviews)  {
    if s.Id == 0 {
        model.Model = common.Model{ Id: s.Id }
    }
    model.UserId = s.UserId
    model.AdvertisementId = s.AdvertisementId
    model.Rating = s.Rating
    model.Content = s.Content
    model.Images = s.Images
    model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

func (s *ReviewsUpdateReq) GetId() interface{} {
	return s.Id
}

// ReviewsGetReq 功能获取请求参数
type ReviewsGetReq struct {
     Id int `uri:"id"`
}
func (s *ReviewsGetReq) GetId() interface{} {
	return s.Id
}

// ReviewsDeleteReq 功能删除请求参数
type ReviewsDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *ReviewsDeleteReq) GetId() interface{} {
	return s.Ids
}
